﻿namespace SvGame.Logic;

public static partial class GameLogic
{
    public static InfoTalent InfoTalent(this Talent talent)
    {
        var info = new InfoTalent();
        info.Str = talent.Str;
        info.Int = talent.Int;
        info.Con = talent.Con;
        info.Spi = talent.Spi;
        info.Cps = talent.Cps;
        info.Cor = talent.Cor;
        info.Per = talent.Per;
        info.Kar = talent.Kar;
        return info;
    }
    public static RoleInfoTalent InfoTalent(this Player player)
    {
        var info = new RoleInfoTalent();
        info.TalentBase = player.Talent.InfoTalent();
        info.TalentTemp = player.TalentTemp.InfoTalent();
        return info;
    }
    public static Talent Talent(this InfoTalent talent)
    {
        var info = new Talent();
        info.Str = talent.Str;
        info.Int = talent.Int;
        info.Con = talent.Con;
        info.Spi = talent.Spi;
        info.Cps = talent.Cps;
        info.Cor = talent.Cor;
        info.Per = talent.Per;
        info.Kar = talent.Kar;
        return info;
    }
    public static bool TalentCheckCreate(InfoTalent t)
    {
        var total = t.Str + t.Int + t.Con + t.Spi + t.Cps + t.Cor + t.Per + t.Kar;
        var 玩家默认天赋总值 = Conf.ValueInt(EGlobalId.玩家默认天赋总值);
        var 玩家默认天赋最大 = Conf.ValueInt(EGlobalId.玩家默认天赋最大);
        var 玩家默认天赋最小 = Conf.ValueInt(EGlobalId.玩家默认天赋最小);
        if (total != 玩家默认天赋总值)
        {
            return false;
        }
        if (t.Str < 玩家默认天赋最小 || t.Str > 玩家默认天赋最大
            || t.Int < 玩家默认天赋最小 || t.Int > 玩家默认天赋最大
            || t.Con < 玩家默认天赋最小 || t.Con > 玩家默认天赋最大
            || t.Spi < 玩家默认天赋最小 || t.Spi > 玩家默认天赋最大
            || t.Cps < 玩家默认天赋最小 || t.Cps > 玩家默认天赋最大
            || t.Cor < 玩家默认天赋最小 || t.Cor > 玩家默认天赋最大
            || t.Per < 玩家默认天赋最小 || t.Per > 玩家默认天赋最大
            || t.Kar < 玩家默认天赋最小 || t.Kar > 玩家默认天赋最大)
        {
            return false;
        }
        return true;
    }
}
